<?

class CQSimpleList
{
  function __construct(&$itemList)
  {
    $this->items = &$itemList;
    $this->id_field = 'ID';
    $this->itemClickUrl = 'id=';
    $this->showColumns = array();
    if (sizeof($this->items) > 0)
      foreach ($this->items[0] as $k => $v)
        $this->showColumns[] = $k;
    $this->idField = 'ID';
  }

  function display()
  {
    if (sizeof($this->items)>0)
    {
    ?><table cellspacing="1" cellpadding="4" class="listview"><thead><tr><?
    foreach ($this->showColumns as $column)
    {
      ?><td><?= getDefault($this->columnCaption[$column], $column) ?></td><?
    }
    ?></tr></thead><tbody class="databody"><?
    foreach ($this->items as $item)
    {
      $itemEditUrl = $this->itemClickUrl.$item[$this->idField];
      ?><tr onclick="document.location='<?= $itemEditUrl ?>';"><?
      foreach ($this->showColumns as $column)
      {
        ?><td valign="top"><?
        $colContent = $item[$column];
        if (isset($this->columnTemplate[$column]))
        {
          eval($this->columnTemplate[$column]);
        }
        else
          print($colContent);
        ?></td><?
      }
      ?></tr><?
    }
    ?></tbody></table><?
    return(true);
    }
    else
      return(false);
  }

}

?>